class Solution {//leetcode64——二进制求和
public:
    string addBinary(string a, string b) {
        int n=a.size()-1,m=b.size()-1,carry=0;
        string ret;
        while(n>=0||m>=0){
            int num1=0,num2=0;
            if(n>=0) num1=a[n--]-'0';
            if(m>=0) num2=b[m--]-'0';
            carry=carry+num1+num2;
            ret.push_back((carry%2)+'0');
            carry/=2;
        }
        if(carry) ret.push_back(carry+'0');
        reverse(ret.begin(),ret.end());
        return ret;
    }
};